package com.zengdada.authority.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @Auther: 12614
 * @Contact: 1261438511@qq.com
 * @Date: 2019-02-22 09:38
 * @Description:
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
@ConditionalOnExpression("${swagger.enable:true}")
public class SwaggerConfig {
    @Bean
    public Docket SwaggerConfigMvcPlugin() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.sybenya.*.controller"))
//                .paths(regex("s/api/.*"))
                .build()
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(false);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("权限平台Api")
                .description("springBoot + swagger2")
                .termsOfServiceUrl("")
                .version("0.0.20")
                .contact(new Contact("zeng", "", "1261438511@qq.com"))
                .build();
    }
}
